<template>
    <el-main>
        <el-table :height="tableHeight" :data="tableList" border stripe>
            <el-table-column prop="goodsId" label="商品号"></el-table-column>
            <el-table-column prop="goodsName" label="商品名"></el-table-column>
            <el-table-column prop="openId" label="发布者"></el-table-column>
            <el-table-column prop="commentText" label="评论内容"></el-table-column>
            <el-table-column prop="createTime" label="发布时间"></el-table-column>
            <el-table-column label="操作" width="200">
                <template #default="scope">
                    <el-button style="margin-left: 50px;" :icon="Delete" type="danger" size="default" @click="deleteBtn(scope.row.commentId)" >删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <!--分页-->
        <el-pagination @size-change="sizeChange" @current-change="currentChange" :current-page.sync="listParm.page"
            layout="total, prev, pager, next, jumper" :total="listParm.totalSize" background>
        </el-pagination>
    </el-main>
</template>

<script setup lang="ts">
import { Delete } from '@element-plus/icons-vue'
import useCommentTable from '@/module/comment/useCommentTable';
import { onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { userStore } from '@/store/user';
const router = useRouter();
const store = userStore();
onMounted(() => {
    store.autoLogin(); // 尝试自动登录
    if (store.$state.key != '' && store.$state.key) {
        router.push('/comment');
    } else {
        router.push('/login');
    }
});
//表格业务
const { listParm, tableList,tableHeight,sizeChange,currentChange,deleteBtn } = useCommentTable()
</script>

<style scoped></style>